package com.mz.ozy.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mz.ozy.R;
import com.mz.ozy.activity.me.MsgDetailActivity;
import com.mz.ozy.bean.MsgBean;
import com.mz.ozy.bean.OrderMsgBean;
import com.mz.ozy.utils.Utils;

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 */

public class OrderMsgAdapter extends RecyclerView.Adapter<OrderMsgAdapter.MyViewHolder> {

    private Context mContext;
    List<OrderMsgBean.PageBean.PageItemsBean> mBeanList;

    public OrderMsgAdapter(Context context, List<OrderMsgBean.PageBean.PageItemsBean> mBeanList) {
        mContext = context;
        this.mBeanList = mBeanList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_ordermsg, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        final OrderMsgBean.PageBean.PageItemsBean bean = mBeanList.get(position);
        holder.titleTv.setText(bean.getMsg());
        holder.timeTv.setText(Utils.interceptTime(bean.getCreatime()));
//        holder.mLlItem.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(mContext, MsgDetailActivity.class);
//                intent.putExtra("id", bean.getId());
//                intent.putExtra("title", bean.getTitle());
//                intent.putExtra("time", bean.getCreated());
//                intent.putExtra("content", bean.getTitle());
//                mContext.startActivity(intent);
//            }
//        });


    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.timeTv)
        TextView timeTv;
//        @BindView(R.id.contentTv)
//        TextView contentTv;
//        @BindView(R.id.ll_item)
//        LinearLayout mLlItem;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }


    }



}
